****************************************************
** Read in the raw data
****************************************************
local loader = 1
local checker = 0

if `loader' == 1 {
	forvalues i = 0(1)3 {
		display ""
		display ""
		display ""
		display "Working on year `i'"
		display ""
		display ""
		display ""
		display ""
		
		if `i'<10 {
			infile using dictionary.dct, using(../Mort200`i'/MULT200`i'.USAllCnty.txt) clear
			drop if stateres=="GU" | stateres=="VI" | stateres=="PR" | ///
			stateres=="ZZ" | stateres=="MP" | stateres=="AS" | stateres=="ON" | ///
			stateres=="QC" | stateres=="XX"
			foreach x of varlist cond* {
				replace `x' = trim(`x')
			}
			compress
			save ../Mort200`i'/rawish200`i'.dta, replace
		}
		else {
			infile using dictionary.dct, using(../Mort20`i'/MULT20`i'.USAllCnty.txt) clear
			drop if stateres=="GU" | stateres=="VI" | stateres=="PR" | ///
			stateres=="ZZ" | stateres=="MP" | stateres=="AS" | stateres=="ON" | ///
			stateres=="QC" | stateres=="XX"
			foreach x of varlist cond* {
				replace `x' = trim(`x')
			}
			compress
			save ../Mort20`i'/rawish20`i'.dta, replace
		}

	}
}


if `checker' == 1 {
	use ../Mort2004/rawish2004.dta, clear
	forvalues i = 5(1)14 {
		if `i'<10 {
			append using ../Mort200`i'/rawish200`i'.dta
		}
		else {
			append using ../Mort20`i'/rawish20`i'.dta
		}
	}
	** check it
	** add up number of deaths with a heroin code.
	forvalues i = 1(1)20 {
		gen heroin`i' = (cond`i'=="T401")
	}
	egen heroins = rowtotal(heroin*)
	tab death_year heroins
	
}

